package android.explorer;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.explorer.interfaces.CallBack;
import android.widget.EditText;

public class InputBox extends AlertDialog.Builder{
	private String result="";
	public InputBox(Context ct,String title,String defaultText,final CallBack cb) {
		super(ct);
		this.setTitle(title);
		final EditText input = new EditText(ct);
		setView(input);
		input.setText(defaultText);
		this.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int whichButton) {
				try{
					cb.onOkClick(input.getText().toString().trim());
				}catch(Exception e){}
			}
		});
		
		this.setNegativeButton("Cancel",
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int whichButton) {
						result="";
						dialog.cancel();
					}
				});
	}
	public String getResult(){
		return result;
	}
}
